<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */

/**
 * Smarty {once}{/once} block plugin
 *
 * Type:     block function<br>
 * Name:     once<br>
 * Purpose:  that block will shows just once<br>
 * @param array
 * <pre>
 * Params:   name: string
 * </pre>
 * @author Alex <qfox@ya.ru> Yaroshevich
 * @param string contents of the block
 * @param Smarty clever simulation of a method
 * @return string string $content
 */
function smarty_block_once( $params, $content, &$smarty )
{
	if( is_null($content) )
		return '';
	
	$_code = md5( isset( $params['name'] ) ? $params['name'] : $content );
	
	if( !isset( $smarty ->__once_showed )
	 || !is_array( $smarty ->__once_showed ) )
		$smarty ->__once_showed = array( );
	
	if( isset( $smarty ->__once_showed[ $_code ] ) )
		return '';
	
	$smarty ->__once_showed[ $_code ] = 1;
	
	return $content;
}

/* vim: set expandtab: */

?>
